#pragma once

#include "rclcpp/rclcpp.hpp"

#include "muduo/net/EventLoop.h"
#include "muduo/net/EventLoopThread.h"

#include <atomic>

namespace decision::adas {

class World;

class AdasApplication : public rclcpp::Node {
public:
    AdasApplication(World& world, const std::string& name, double fps);
    virtual ~AdasApplication();

    const std::string& name();

    void start();
    void stop();

    virtual void detect() = 0;

protected:
    rclcpp::Logger logger_;

protected:
    World& this_world_;

private:
    const std::string name_;
    double fps_;

    std::atomic<bool> working_;

    muduo::net::EventLoop* loop_;
    muduo::net::EventLoopThread thread_;
    muduo::net::TimerId timer_;
};

} // namespace decision::adas
